Skip to content

Line-matching rewriter#940

Draft
amomchilov wants to merge 7 commits into
Alex/Options-objectfrom
Alex/line-matching
Draft

Line-matching rewriter#940
amomchilov wants to merge 7 commits into
Alex/Options-objectfrom
Alex/line-matching

Conversation

@amomchilov

Copy link
Copy Markdown
Contributor

No description provided.

@amomchilov amomchilov force-pushed the Alex/line-matching branch 2 times, most recently from 9aad209 to df5c587 Compare June 6, 2026 00:32
@amomchilov amomchilov force-pushed the Alex/line-matching branch from df5c587 to 754641a Compare June 15, 2026 17:19
@amomchilov amomchilov changed the base branch from main to graphite-base/940 June 16, 2026 22:54
@amomchilov amomchilov force-pushed the Alex/line-matching branch from 754641a to 273ef3e Compare June 16, 2026 22:55
@amomchilov amomchilov changed the base branch from graphite-base/940 to Alex/Options-object June 16, 2026 22:55
@amomchilov

amomchilov commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@amomchilov amomchilov force-pushed the Alex/Options-object branch 2 times, most recently from eeb32d8 to d5692f6 Compare June 17, 2026 14:59
@amomchilov amomchilov force-pushed the Alex/line-matching branch from 273ef3e to 4dafa78 Compare June 17, 2026 14:59
next
end

rewrite_annotation(annotation, is_known: true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLM review pointed out that this is getting called per signature, so we could have a case of duplicate RBS_REWRITTEN_ANNOTATION being inserted

# @override
#: (Integer) -> void
#: (String) -> void
def foo(x); end

would be translated into

# RBS_REWRITTEN_ANNOTATION: RBS_REWRITTEN_ANNOTATION: @override

# @override
#: (RBS::Signature) -> void
def rewrite_discarded_overload(signature)
@rewriter << Source::Insert.new(signature.location.start_offset + 1, " RBS_DISCARDED_OVERLOAD")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another LLM edge case find: This isn't considering multi line signatures and the RBS syntax sticks around.

#: (Integer,
#|  String) -> void

gets translated into

# RBS_DISCARDED_OVERLOAD: (Integer,
#|  String) -> void

@amomchilov amomchilov force-pushed the Alex/line-matching branch from 4dafa78 to 846ea47 Compare June 17, 2026 19:01
@amomchilov amomchilov force-pushed the Alex/Options-object branch from d5692f6 to 7654edc Compare June 17, 2026 19:01
@amomchilov amomchilov force-pushed the Alex/line-matching branch from 846ea47 to 0bdd70e Compare June 17, 2026 19:10
#: LineMatchedRBIFormat
attr_reader :default
end
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be used similar to HumanReadableRBIFormat in lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs.rb? Curious why it's not being triggered in this PR.

#| insert_pos: Integer,
#| sorbet_replacement: String?
#| ) -> void
def apply_class_annotation(annotation, parent_node:, insert_pos:, sorbet_replacement:) = raise

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are making this class harder to read but I'm not sure what we can do. One alternative I kinda like it to move these abstract methods to HumanReadableTranslator instead. Call sites in this class would then delegate to the appropriate "mode" that's being set, @translation_mode.apply_class_anotation. It wouldn't get rid of the abstract but make the intent more clear. Wdyt? Maybe as a future improvement to not hold up the PR.

#{expected_line_matched_format}

Actual rewritten output:
#{rewritten_output}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message talks about line-matched format but rewritten_output is human readable output at this stage.

@amomchilov amomchilov force-pushed the Alex/line-matching branch from 0bdd70e to a756398 Compare June 18, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants